#!/usr/bin/python
#Filename: create_db.py

import sqlite3
import sys

fname = sys.argv[1]
dbname = sys.argv[2]

f = file(fname)
cx = sqlite3.connect(dbname);
cu = cx.cursor()

cu.execute("create table number_location (id integer primary key, \
		mobile varchar UNIQUE, region varchar, \
		city varchar, sim_type varchar)")
while True:
	line = f.readline()
	if len(line) <= 0:
		break
	item = line.split('\t')
	#cu.execute("insert into number_location values(" + item[0] + ", " + item[1] \
	#		+ ", " + item[2] + ", " + item[3] + ", " + item[4] + ")")
	cu.execute("insert into number_location values(" + ", ".join(item) + ")")
	cx.commit()

